<template>
	<view class="outer">
		<view class="inputPart">
			<uni-easyinput class="uni-mt-5 input1" trim="all" v-model="user.userAccount" placeholder="账号"
				style="margin-bottom: 30rpx;">
			</uni-easyinput>
			<uni-easyinput class="uni-mt-5 input1" trim="all" v-model="user.userPhone" placeholder="手机号" style="margin-bottom: 30rpx;">
			</uni-easyinput>
			<uni-easyinput class="uni-mt-5 input1" trim="all" v-model="user.userPwd" placeholder="密码" style="margin-bottom: 30rpx;">
			</uni-easyinput>
			<uni-easyinput class="uni-mt-5 input1" trim="all" v-model="user.userName" placeholder="姓名" style="margin-bottom: 30rpx;">
			</uni-easyinput>
			<!-- <uni-easyinput class="uni-mt-5 input2" suffixIcon="paperplane-filled" v-model="code" placeholder="验证码"
				@iconClick="sendCode"></uni-easyinput> -->
		</view>
		<view class="btnPart">
			<button class="btn" type="primary" @click="Register">Register</button>
		</view>
		<view class="otherPart">
			<view class="other1">---------------</view>
			<view class="other2">其他登录方式</view>
			<view class="other3">-------------</view>
		</view>
		<view class="loginWayPart" @click.native="loginPage">
			<uni-icons type="contact" color="#fff" size="45"></uni-icons>
			<view class="">账号密码登录</view>
		</view>

		<!-- <uni-notice-bar class="tip" show-icon text="注册将发送验证码至手机 , 验证码即登录密码。" /> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user: {
					userAccount: "",
					userPhone: "",
					userPwd:"",
					userName:""
				},
				code: ""
			};
		},
		methods: {
			Register() {
				if (this.user.userAccount == "" || this.user.userPhone == "" || this.user.userPwd == "") {
					uni.showToast({
						title: '请将信息填写完整',
						duration: 2000,
						icon: "error"
					});
					return;
				}
				// 发送验证码
				uni.request({
					url: "api/custom-server/register",
					data: {
						userAccount: this.user.userAccount,
						userPhone: this.user.userPhone,
						userPwd:this.user.userPwd,
						userName:this.user.userName
					},
					method: 'POST',
					success: (res) => {
						console.log(res);
						if (res.data.code == 10003) {
							uni.showToast({
								title: "手机号已存在，请勿重复注册",
								icon: "error",
								duration: 2000
							})
							return;
						}
						if (res.data.code == 200) {
							uni.showToast({
								title: "注册成功",
								icon: "success",
								duration: 2000
							})
							setTimeout(function() {
								uni.reLaunch({
									url: "/pages/login/login",
								})
							}, 2000);
						}
					}
				})
			},
			loginPage() {
				uni.reLaunch({
					url: "/pages/login/login",
				})
			}
		},


	}
</script>

<style lang="scss">
	page {
		height: 100%;
	}

	.inputPart {
		margin-top: 150rpx;


		.input1 {
			width: 550rpx;
			margin: 0 auto;
		}

		.input2 {
			width: 550rpx;
			margin: 30rpx auto;
		}
	}

	.btnPart {
		margin-top: 70rpx;

		.btn {
			width: 550rpx;
			margin: 30rpx auto;
		}
	}

	.otherPart {
		width: 550rpx;
		margin: 0 auto;
		margin-top: 600rpx;

		.other1 {
			float: left;
		}

		.other2 {
			float: left;
		}

		.other3 {
			// float: left;
		}
	}

	.loginWayPart {
		width: 140rpx;
		height: 140rpx;
		margin: 0 auto;
		margin-top: 40rpx;
		background-color: gray;
		text-align: center;
		border-radius: 100rpx;
		background-color: #020202;
		color: #fff;
		font-size: 22rpx;
	}

	.tip {
		position: fixed;
		top: var(--window-top);
	}
</style>
